﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Xml.Serialization;

namespace XEvents.Library
{
    [XmlRoot("Predicates")]
    public class PredicateCollection : List<Predicate>
    {
        public PredicateCollection(IEnumerable<Predicate> preds)
            : base(preds)
        { }

        public List<String> Comparators
        {
            get
            {
                return (from p in this
                        where p.PredicateType == PredicateType.Comparator
                        select p.Package.Name + "." + p.Name).ToList();
            }
        }

        public List<String> SourceColumns
        {
            get
            {
                return (from p in this
                        where p.PredicateType == PredicateType.Source
                        select p.Package.Name + "." + p.Name).ToList();
            }
        }

        public Predicate this[string name]
        {
            get { return this.ToDictionary(n => n.Name, n => n)[name]; }
        }
    }
}
